#include <bits/pthreadtypes.h>

typedef struct pthread_rwlock
{
	int active_readers; /* -1 when writer lock locked, >0 when read lock locked */
	int pending_readers;
	int pending_writers;
	pthread_mutex_t mutex;
	pthread_cond_t ok_to_read;
	pthread_cond_t ok_to_write;
} pthread_rwlock_t ;

int pthread_rwlock_init(pthread_rwlock_t * lock /*, pthread_rwlockattr_t *attr*/);

int pthread_rwlock_destroy(pthread_rwlock_t * lock);

int pthread_rwlock_rdlock(pthread_rwlock_t * lock) ;

int pthread_rwlock_wrlock(pthread_rwlock_t * lock);

int pthread_rwlock_unlock(pthread_rwlock_t * lock);


